package com.kun.controller.foreign;

import com.kun.entity.User;
import com.kun.result.Result;
import com.kun.service.impl.UserServiceImpl;
import com.kun.util.MD5Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author SunKun
 * @since 2021-06-14
 */
@RestController
@Slf4j //日志
@CrossOrigin  //允许跨域
@ResponseBody
@RequestMapping("/kun/foreign/user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;

    @PostMapping("/signIn")
    public Result signIn(@RequestBody User user){
        try {
            User tUser = userService.queryUser(user);
            return Result.ok().message("提示: 登录成功!").data("user",tUser);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error().message("提示: " + e.getMessage());
        }
    }
}

